<!-- 定时器 setInterval 和 暂停定时器 clearInterval  -->

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<button id="btn">停下</button>

    <!-- setInterval(fun(),time) 每隔time就定时一下 -->
    <script>
        const btn = document.querySelector('#btn');
        btn.addEventListener('click', () => {
            console.log('停下了');
            clearInterval(interval);
        })

        var i = 1;
        let j = 2;

        console.log(this);

        // 定时器对象 返回结果是定时器的id
        let interval = setInterval(() => {
            // call 作用域链查找
            // this -> window
            console.log(j++);
        }, 3000)

        // console.log(interval, '------')//返回结果是定时器的id
    </script>
</body>

</html>